import 'package:flutter/material.dart';

//绝对布局
class StackWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: new AppBar(
          title: new Text("Stack"),
          leading: new BackButton(),
        ),
        body: new Stack(
          //(0,0)是中心, X:左为负右为正,Y:上为负下为正
          alignment: const Alignment(0.6, 0.6),
          /* 定义如何设置non-positioned节点尺寸，默认为loose
          loose：子节点宽松的取值，可以从min到max的尺寸；
          expand：子节点尽可能的占用空间，取max尺寸；
          passthrough：不改变子节点的约束条件。
           */
          fit: StackFit.loose,
          //超过的部分是否裁剪掉（clipped
          // overflow: Overflow.visible,
          children: <Widget>[
            CircleAvatar(
              backgroundImage: AssetImage('assets/img/icon_header.jpg'),
              radius: 100,
            ),
            Container(
              padding: const EdgeInsets.all(2),
              decoration: BoxDecoration(
                color: Colors.black45,
              ),
              child: Text(
                'Flutter',
                style: TextStyle(
                    fontSize: 20,
                    fontWeight: FontWeight.bold,
                    color: Colors.white),
              ),
            )
          ],
        ));
  }
}
